import React, { Component } from 'react'
import Navbar from './Navbar'
import Sidebar from './Sidebar'

export default class App extends Component {
  state = {
    sidebarOpened: true,
  }
  render() {
    return (
      <div>
        <Navbar
          event={(args) => {
            console.log('父组件中定义的事件', args)
            this.setState({ sidebarOpened: !this.state.sidebarOpened })
          }}
        ></Navbar>
        {this.state.sidebarOpened && <Sidebar></Sidebar>}
      </div>
    )
  }
}

/**
 * 父传子
 * 1. 属性
 * 2. ref引用 调用
 *
 * 子传父
 * 1. 调用 父传过来的 回调函数
 */
